<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<p id="p1">das</p>
	</body>
	<script type="text/javascript">
		var elentA = {
			//添加监听事件的兼容处理。
			addEvent:function(element,type,handle){
				//实现各种浏览器的监听事件兼容问题
				if(element.addEventListener){
					element.addEventListener(type,handle,false);
				}else if(element.attachEvent){
					var newtype = "on" + type;
					element.attachEvent(newtype,handle,false);
				}else{
					var newType = "on" + type;
					element[newType] = handle;//等同于  element.onclick = 
				}
			}
			,
			//移除的兼容处理
			deleteEvent:function(element,type,handle){
				if(element.removeEventListener){
					element.removeEventListener(type,handle,false);
				}else if(element.detachEvent){
					var newtype = "on" + type;
					element.detachEvent(newtype,handle,false);
				}else{
					element["on" + type] = null;
				}
			}
		}
		
		var p1 = document.getElementById("p1");
		//监听事件，，，兼容所有的浏览器
		elentA.addEvent(p1,"click",aaaaa);
		//移除事件
		elentA.deleteEvent(p1,"click",aaaaa);
		function aaaaa(){
			alert(111);
		}
	</script>
</html>
